package com.zl.controller;

import com.zl.entity.QuarkusUser;
import com.zl.service.QUserService;
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Path("/hello")
public class QUserResource {
    @Inject
    QUserService qUserService;



    @GET
    @Path("/say")
    @Produces(MediaType.TEXT_PLAIN)
    public String say(@QueryParam("name") String name) {
        return qUserService.say(name);
    }

    @POST
    @Path("/saveAll")
    @Produces(MediaType.APPLICATION_JSON)
    public String saveAll(List<QuarkusUser> users) {
        qUserService.saveAll(users);
        return "ok";
    }

    @GET
    @Path("/list")
    @Produces(MediaType.APPLICATION_JSON)
    public List<PanacheEntityBase> list() {
        return qUserService.list();
    }


}